package com.xy.biz.fd.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.biz.fd.domain.req.documentHistory.ListDocumentHistoryRequest;
import com.xy.biz.fd.domain.req.documentHistory.SaveDocumentHistoryRequest;
import com.xy.biz.fd.domain.req.documentHistory.TypeDocumentHistoryRequest;
import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.fd.domain.bo.DocumentHistoryBO;
import com.xy.biz.fd.domain.po.DocumentHistoryPO;
import com.xy.biz.fd.domain.query.DocumentHistoryQuery;
import com.xy.biz.fd.domain.resp.GetDocumentHistoryResponse;

/**
 * 
 * 
 * @author wcs
 * @date 2021-2-3
 */
public class DocumentHistoryConverter {
	
	public static DocumentHistoryPO toPO(DocumentHistoryBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentHistoryPO(), true);
	}
	
	public static List<DocumentHistoryPO> toPO(Collection<DocumentHistoryBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentHistoryPO(), true);
	}
	
	public static DocumentHistoryBO fromPO(DocumentHistoryPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentHistoryBO());
	}
	
	public static List<DocumentHistoryBO> fromPO(Collection<DocumentHistoryPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentHistoryBO());
	}
	
	public static DocumentHistoryBO toBO(SaveDocumentHistoryRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentHistoryBO(), true);
	}
	
	public static List<DocumentHistoryBO> toBO(Collection<SaveDocumentHistoryRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentHistoryBO(), true);
	}
	
	public static GetDocumentHistoryResponse toResponse(DocumentHistoryBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetDocumentHistoryResponse());
	}
	
	public static List<GetDocumentHistoryResponse> toResponse(Collection<DocumentHistoryBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetDocumentHistoryResponse());
	}
	
	public static DocumentHistoryQuery toQuery(ListDocumentHistoryRequest source) {
		if(null == source) {
			return null;
		}
		DocumentHistoryQuery target = new DocumentHistoryQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

	//类型查找
	public static DocumentHistoryQuery toQuery(TypeDocumentHistoryRequest source) {
		if(null == source) {
			return null;
		}
		DocumentHistoryQuery target = new DocumentHistoryQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
